#!/usr/bin/env python
# encoding: utf-8
"""
@Author: Beam
@Mail:506556658@qq.com
@file: redis-list操作.py
@time: 2017/5/25 10:15
"""

import redis

pool = redis.ConnectionPool(host='192.168.6.248',port=63780,db=8,password='liang123456')  #连接池方式连接,用第6这个库
r = redis.Redis(connection_pool=pool)     #建立redis连接

# r.lpush('info3','Beam','25','man','it','1992')
# r.rpush('info4','Mity','25','lady','manager','1992')
# print(r.lrange('info3',0,-1))
# print(r.lrange('info4',0,-1))


# r.lpushx('info3','left')  #TypeError: rpushx() takes 3 positional arguments but 4 were given
# r.rpushx('info3','right')
# print(r.lrange('info3',0,-1))

# print(r.llen('info3'))
# print(r.lrange('info3',0,-1))

# r.linsert('info3',"before",'man','BEFORE')
# r.linsert('info3',"after",'man','AFTER')
# print(r.lrange('info3',0,-1))

# print(r.lrange('info3',0,-1))
# r.lset("info3",6,'26')  #修改下标为6的value
# print(r.lrange('info3',0,-1))

# r.lrem('info3','Beam',0)
# print(r.lrange('info3',0,-1))

# r.lpop('info3')
# print(r.lrange('info3',0,-1))
# r.rpop('info3')
# print(r.lrange('info3',0,-1))


# print(r.lrange('info3',0,-1))
# print(r.lindex('info3',3))

# print(r.lrange('info3',0,-1))
# r.ltrim('info3',2,3)
# print(r.lrange('info3',0,-1))


# r.lpush('names1','Beam','dog','cat')
# r.lpush('names2','Jack','Mity')


# print(r.lrange('names1',0,-1))
# print(r.lrange('names2',0,-1))
# r.rpoplpush('names1','names2')
# print(r.lrange('names1',0,-1))
# print(r.lrange('names2',0,-1))

# r.lpush('info1','Beam','25','man','it','1992')
# print(r.lrange('info1',0,-1))
# r.blpop('info1',30)
# print(r.lrange('info1',0,-1))


# print(r.lrange('names1',0,-1))
# print(r.lrange('names2',0,-1))
# r.brpoplpush('names1','names2',30)
# print(r.lrange('names1',0,-1))
# print(r.lrange('names2',0,-1))



